package com.ruoyi.system.controller.car4s_controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.car4s_domain.Car4sRepairInfo;
import com.ruoyi.system.service.car4s_service.ICar4sRepairInfoService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 维修信息单Controller
 * 
 * @author LK
 * @date 2024-06-29
 */
@RestController
@RequestMapping("/system/car_4s_repair_info")
public class Car4sRepairInfoController extends BaseController
{
    @Autowired
    private ICar4sRepairInfoService car4sRepairInfoService;

    /**
     * 查询维修信息单列表
     */
    @PreAuthorize("@ss.hasPermi('system:car_4s_repair_info:list')")
    @GetMapping("/list")
    public TableDataInfo list(Car4sRepairInfo car4sRepairInfo)
    {
        startPage();
        List<Car4sRepairInfo> list = car4sRepairInfoService.selectCar4sRepairInfoList(car4sRepairInfo);
        return getDataTable(list);
    }

    /**
     * 导出维修信息单列表
     */
    @PreAuthorize("@ss.hasPermi('system:car_4s_repair_info:export')")
    @Log(title = "维修信息单", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, Car4sRepairInfo car4sRepairInfo)
    {
        List<Car4sRepairInfo> list = car4sRepairInfoService.selectCar4sRepairInfoList(car4sRepairInfo);
        ExcelUtil<Car4sRepairInfo> util = new ExcelUtil<Car4sRepairInfo>(Car4sRepairInfo.class);
        util.exportExcel(response, list, "维修信息单数据");
    }

    /**
     * 获取维修信息单详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:car_4s_repair_info:query')")
    @GetMapping(value = "/{repairId}")
    public AjaxResult getInfo(@PathVariable("repairId") Long repairId)
    {
        return success(car4sRepairInfoService.selectCar4sRepairInfoByRepairId(repairId));
    }

    /**
     * 新增维修信息单
     */
    @PreAuthorize("@ss.hasPermi('system:car_4s_repair_info:add')")
    @Log(title = "维修信息单", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody Car4sRepairInfo car4sRepairInfo)
    {
        return toAjax(car4sRepairInfoService.insertCar4sRepairInfo(car4sRepairInfo));
    }

    /**
     * 修改维修信息单
     */
    @PreAuthorize("@ss.hasPermi('system:car_4s_repair_info:edit')")
    @Log(title = "维修信息单", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody Car4sRepairInfo car4sRepairInfo)
    {
        return toAjax(car4sRepairInfoService.updateCar4sRepairInfo(car4sRepairInfo));
    }

    /**
     * 删除维修信息单
     */
    @PreAuthorize("@ss.hasPermi('system:car_4s_repair_info:remove')")
    @Log(title = "维修信息单", businessType = BusinessType.DELETE)
	@DeleteMapping("/{repairIds}")
    public AjaxResult remove(@PathVariable Long[] repairIds)
    {
        return toAjax(car4sRepairInfoService.deleteCar4sRepairInfoByRepairIds(repairIds));
    }
}
